package com.qys.livesMall.shop.controller.sys;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qys.livesMall.common.result.R;
import com.qys.livesMall.framework.view.BaseQuery;
import com.qys.livesMall.shop.modal.entity.SysShopDataConsume;
import com.qys.livesMall.shop.modal.vo.SysShopDataConsumeVO;
import com.qys.livesMall.shop.service.SysShopDataConsumeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * 店铺流量消耗表(SysShopDataConsume)表控制层
 *
 * @author makejava
 * @since 2023-07-04 10:12:54
 */
@RestController
@RequestMapping("/sys/sysShopDataConsume")
@RequiredArgsConstructor
@Tag(name = "sys-店铺流量消耗管理", description = "sys-店铺流量消耗管理")
public class SysShopDataConsumeController {

    private final SysShopDataConsumeService sysShopDataConsumeService;

    /**
     * 分页查询所有数据
     *
     * @param dto 分页对象
     * @return 所有数据
     */
    @PostMapping("/selectAll")
    @Operation(summary = "分页查询")
    public R<IPage<SysShopDataConsumeVO>> selectAll(@RequestBody BaseQuery dto) {
        return R.ok(sysShopDataConsumeService.selectAll(dto));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    @Operation(summary = "根据ID查询")
    public R<SysShopDataConsume> selectOne(@PathVariable Serializable id) {
        return R.ok(sysShopDataConsumeService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param sysShopDataConsume 实体对象
     * @return 新增结果
     */
    @PostMapping("/add")
    @Operation(summary = "新增")
    public R<?> insert(@RequestBody SysShopDataConsume sysShopDataConsume) {
        return R.ok(sysShopDataConsumeService.save(sysShopDataConsume));
    }

    /**
     * 修改数据
     *
     * @param sysShopDataConsume 实体对象
     * @return 修改结果
     */
    @PostMapping("/update")
    @Operation(summary = "修改")
    public R<?> update(@RequestBody SysShopDataConsume sysShopDataConsume) {
        return R.ok(sysShopDataConsumeService.updateById(sysShopDataConsume));
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @PostMapping("/delete")
    @Operation(summary = "删除")
    public R<?> delete(@RequestParam("idList") List<Long> idList) {
        return R.ok(sysShopDataConsumeService.removeByIds(idList));
    }
}

